# 作者：小七
# 2025年01月04日

import test_exception_module
def use_exception():
    while True:
        try:
            num = int(input("请输入一个数字："))
            print(num)
            break
        except:
            print("请输入正确的数字")


def use_exception2():
    try:
        num = int(input("请输入整数："))
        result = 8 / num
        print(result)
    except ValueError:
        print("请输入正确的整数")
    except ZeroDivisionError:
        print("除 0 错误")


def use_exception3():
    try:
        num = int(input("请输入整数："))
        result = 8 / num
        print(result)
    except ValueError:
        print("请输入正确的整数")
    except Exception as e:
        print(e)


def use_exception4():
    try:
        num = int(input("请输入整数："))
        result = 8 / num
        print(result)
    except ValueError:
        print("请输入正确的整数")
    except ZeroDivisionError:
        print("除 0 错误")
    except Exception as result:
        print("未知错误 %s" % result)
    else:
        print("正常执行")
    finally:
        print("执行完成，但是不保证正确")


def use_exception5():
    try:
        test_exception_module.test()
    except Exception as e:
        print(e)
        print(e.__traceback__.tb_frame.f_globals["__file__"])
        print(e.__traceback__.tb_lineno)


if __name__ == '__main__':
    # use_exception2()
    # use_exception3()
    # use_exception4()
    use_exception5()
